Conversation
| #include <utility> | ||
|
|
||
| // Функция, которую мы тестируем | ||
| std::pair<int, int> find_sum(const std::vector<int>& nums, int target) { |
There was a problem hiding this comment.
warning: function 'find_sum' can be made static or moved into an anonymous namespace to enforce internal linkage [misc-use-internal-linkage]
| std::pair<int, int> find_sum(const std::vector<int>& nums, int target) { | |
| мы тестируемstatic |
| @@ -0,0 +1,5 @@ | |||
| #include <vector> | |||
There was a problem hiding this comment.
warning: 'vector' file not found [clang-diagnostic-error]
#include <vector>
^| return result; | ||
| void Stack::display() { | ||
| if (arr.empty()) { | ||
| std::cout << "Stack is empty." << std::endl; |
There was a problem hiding this comment.
warning: do not use 'std::endl' with streams; use '\n' instead [performance-avoid-endl]
| std::cout << "Stack is empty." << std::endl; | |
| std::cout << "Stack is empty." << '\n'; |
| for (int i = 0; i < arr.size(); ++i) { | ||
| std::cout << arr[i] << " "; | ||
| } | ||
| std::cout << std::endl; |
There was a problem hiding this comment.
warning: do not use 'std::endl' with streams; use '\n' instead [performance-avoid-endl]
| std::cout << std::endl; | |
| std::cout << '\n'; |
| @@ -0,0 +1,4 @@ | |||
| #include <vector> | |||
There was a problem hiding this comment.
warning: 'vector' file not found [clang-diagnostic-error]
#include <vector>
^| return result; | ||
| void Stack::display() { | ||
| if (arr.empty()) { | ||
| std::cout << "Stack is empty." << std::endl; |
There was a problem hiding this comment.
warning: do not use 'std::endl' with streams; use '\n' instead [performance-avoid-endl]
| std::cout << "Stack is empty." << std::endl; | |
| std::cout << "Stack is empty." << '\n'; |
| for (int i = 0; i < arr.size(); ++i) { | ||
| std::cout << arr[i] << " "; | ||
| } | ||
| std::cout << std::endl; |
There was a problem hiding this comment.
warning: do not use 'std::endl' with streams; use '\n' instead [performance-avoid-endl]
| std::cout << std::endl; | |
| std::cout << '\n'; |
| #include "two_numbers.h" | ||
|
|
||
| // Вспомогательная функция для перехвата вывода | ||
| std::string captureOutput(std::vector<int>& numbers, int len, int target) { |
There was a problem hiding this comment.
warning: function 'captureOutput' can be made static or moved into an anonymous namespace to enforce internal linkage [misc-use-internal-linkage]
| std::string captureOutput(std::vector<int>& numbers, int len, int target) { | |
| для перехвата выводаstatic |
| s | ||
| FindSum(numbers, len, target); | ||
|
|
||
| std::cout.rdbuf(old); |
There was a problem hiding this comment.
warning: unknown type name 's' [clang-diagnostic-error]
));
^| #include "two_numbers.h" | ||
|
|
||
| // Вспомогательная функция для перехвата вывода | ||
| static std::string captureOutput(std::vector<int>& numbers, int len, int target) { |
There was a problem hiding this comment.
warning: function 'captureOutput' declared 'static', move to anonymous namespace instead [misc-use-anonymous-namespace]
для перехвата вывода
^| int main() { return 0; } | ||
| #include "tree.hpp" | ||
|
|
||
| static void printTreeInfo(const BinarySearchTree& bst) { |
There was a problem hiding this comment.
warning: function 'printTreeInfo' declared 'static', move to anonymous namespace instead [misc-use-anonymous-namespace]
static void printTreeInfo(const BinarySearchTree& bst) {
^| } | ||
|
|
||
| int BinarySearchTree::minValue() const { | ||
| if (!root) throw std::runtime_error("Tree is empty"); |
There was a problem hiding this comment.
warning: no member named 'runtime_error' in namespace 'std' [clang-diagnostic-error]
if (!root) throw std::runtime_error("Tree is empty");
^There was a problem hiding this comment.
переименуй файл в .hpp
| @@ -0,0 +1,3 @@ | |||
| #include <vector> | |||
|
|
|||
| void FindSum(std::vector<int>& numbers, int len, int target); | |||
There was a problem hiding this comment.
функция что-то находит, а где результат непонятно
и в тестах пришлось что-то хитрое придумывать, проще вернуть структуру или пару
| #include <stdexcept> | ||
|
|
||
| void Stack::Push(int value) { data_.push(value); } | ||
| void Stack::push(int element) { arr.push_back(element); } |
| if (arr.empty()) { | ||
| throw std::out_of_range("Stack is empty. Cannot find min."); | ||
| } | ||
| return *std::min_element(arr.begin(), arr.end()); |
There was a problem hiding this comment.
тут должна быть сложность О(1), а не О(N)
| #pragma once | ||
| #include <vector> | ||
|
|
||
| std::vector<int> TopologySort(const std::vector<int>& temperatures); No newline at end of file |
There was a problem hiding this comment.
имя функции другое нудно дать
| TEST(TopologySort, Simple) { | ||
| ASSERT_EQ(1, 1); // Stack [] | ||
| } | ||
| TEST(TopologySort, Simple) { ASSERT_EQ(1, 1); } |
| @@ -0,0 +1,32 @@ | |||
| #include <memory> | |||
|
|
|||
| class BinarySearchTree { | |||
There was a problem hiding this comment.
обычное дерево, не сбалансированое(
| ASSERT_EQ(1, 1); // Stack [] | ||
| class AVLTreeTest : public ::testing::Test { | ||
| protected: | ||
| AVLTree tree; |
There was a problem hiding this comment.
warning: member variable 'tree' has protected visibility [cppcoreguidelines-non-private-member-variables-in-classes]
AVLTree tree;
^| void clear() { clear(root); root = nullptr; } | ||
|
|
||
| private: | ||
| Node* root; |
There was a problem hiding this comment.
warning: use default member initializer for 'root' [cppcoreguidelines-use-default-member-init]
task_07/src/tree.hpp:11:
- AVLTree() : root(nullptr) {}
+ AVLTree() : {}| Node* root; | |
| Node* root{nullptr}; |
| void clear(Node* node); | ||
|
|
||
| // Вспомогательные функции | ||
| int height(Node* node) { return node ? node->height : 0; } |
There was a problem hiding this comment.
warning: Undefined or garbage value returned to caller [clang-analyzer-core.uninitialized.UndefReturn]
ные функции
^Additional context
task_07/src/tree.cpp:3: Assuming 'node' is non-null
if (!node) return new Node{key, nullptr, nullptr, 1};
^task_07/src/tree.cpp:3: Taking false branch
if (!node) return new Node{key, nullptr, nullptr, 1};
^task_07/src/tree.cpp:5: Assuming 'key' is < field 'key'
if (key < node->key)
^task_07/src/tree.cpp:5: Taking true branch
if (key < node->key)
^task_07/src/tree.cpp:6: Calling 'AVLTree::insert'
node->left = insert(node->left, key);
^task_07/src/tree.cpp:3: Assuming 'node' is null
if (!node) return new Node{key, nullptr, nullptr, 1};
^task_07/src/tree.cpp:3: Taking true branch
if (!node) return new Node{key, nullptr, nullptr, 1};
^task_07/src/tree.cpp:3: Uninitialized value stored to field 'height'
if (!node) return new Node{key, nullptr, nullptr, 1};
^task_07/src/tree.cpp:6: Returning from 'AVLTree::insert'
node->left = insert(node->left, key);
^task_07/src/tree.cpp:15: Calling 'AVLTree::balance'
n balance(node);
^task_07/src/tree.cpp:69: Calling 'AVLTree::updateHeight'
updateHeight(node);
^task_07/src/tree.hpp:30: Calling 'AVLTree::height'
t(node->right) : 0; }
^task_07/src/tree.hpp:28: 'node' is non-null
ные функции
^task_07/src/tree.hpp:28: '?' condition is true
ные функции
^task_07/src/tree.hpp:28: Undefined or garbage value returned to caller
ные функции
^|
|
||
| class AVLTreeTest : public ::testing::Test { | ||
| protected: | ||
| AVLTree tree; |
There was a problem hiding this comment.
warning: member variable 'tree' has protected visibility [cppcoreguidelines-non-private-member-variables-in-classes]
AVLTree tree;
^| } | ||
|
|
||
| private: | ||
| Node* root; |
There was a problem hiding this comment.
warning: use default member initializer for 'root' [cppcoreguidelines-use-default-member-init]
task_07/src/tree.hpp:11:
- AVLTree() : root(nullptr) {}
+ AVLTree() : {}| Node* root; | |
| Node* root{nullptr}; |
| void clear(Node* node); | ||
|
|
||
| // Вспомогательные функции | ||
| int height(Node* node) { return node ? node->height : 0; } |
There was a problem hiding this comment.
warning: Undefined or garbage value returned to caller [clang-analyzer-core.uninitialized.UndefReturn]
ные функции
^Additional context
task_07/src/tree.cpp:3: Assuming 'node' is non-null
if (!node) return new Node{key, nullptr, nullptr, 1};
^task_07/src/tree.cpp:3: Taking false branch
if (!node) return new Node{key, nullptr, nullptr, 1};
^task_07/src/tree.cpp:5: Assuming 'key' is < field 'key'
if (key < node->key)
^task_07/src/tree.cpp:5: Taking true branch
if (key < node->key)
^task_07/src/tree.cpp:6: Calling 'AVLTree::insert'
node->left = insert(node->left, key);
^task_07/src/tree.cpp:3: Assuming 'node' is null
if (!node) return new Node{key, nullptr, nullptr, 1};
^task_07/src/tree.cpp:3: Taking true branch
if (!node) return new Node{key, nullptr, nullptr, 1};
^task_07/src/tree.cpp:3: Uninitialized value stored to field 'height'
if (!node) return new Node{key, nullptr, nullptr, 1};
^task_07/src/tree.cpp:6: Returning from 'AVLTree::insert'
node->left = insert(node->left, key);
^task_07/src/tree.cpp:15: Calling 'AVLTree::balance'
n balance(node);
^task_07/src/tree.cpp:70: Calling 'AVLTree::updateHeight'
updateHeight(node);
^task_07/src/tree.hpp:36: Calling 'AVLTree::height'
eHeight(Node* node) {
^task_07/src/tree.hpp:31: 'node' is non-null
ные функции
^task_07/src/tree.hpp:31: '?' condition is true
ные функции
^task_07/src/tree.hpp:31: Undefined or garbage value returned to caller
ные функции
^| #include <utility> | ||
| #include <vector> | ||
|
|
||
| class FindSum { |
No description provided.